﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using MobileSales.Model.Util;
using System.ComponentModel.DataAnnotations;
using MobileSales.Model.Localization;

namespace MobileSales.Model.Employees
{
    [DataContract]
    public class Message
    {
        #region Public members
        [DataMember]
        public int Id { get; set; }
        [DataMember]
        public int SenderId { get; set; }
        [DataMember]
        public string SenderLogin { get; set; }
        [DataMember]
        [Display(Name = "Recipient", ResourceType = typeof(ModelStrings))]
        public int RecepientId { get; set; }
        [DataMember]
        public string RecepientLogin { get; set; }
        [DataMember]
        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ValidationStrings))]
        [Display(Name = "Subject", ResourceType = typeof(ModelStrings))]
        public string Subject { get; set; }
        [DataMember]
        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ValidationStrings))]
        [Display(Name = "Content", ResourceType = typeof(ModelStrings))]
        [DataType(DataType.MultilineText)]
        public string Content { get; set; }
        [DataMember(Name="SendDate")]
        private string _sendDate { get; set; }
        public DateTime SendDate
        {
            get
            {
                if (_sendDate != null) return DateUtil.Deserialize(_sendDate);
                return DateTime.MinValue;
            }
            set
            {
                _sendDate = DateUtil.Serialize(value);
            }
        }
        [DataMember(Name = "ReceiveDate")]
        private string _receiveDate { get; set; }
        public DateTime? ReceiveDate
        {
            get
            {
                if (_receiveDate != null) return DateUtil.Deserialize(_receiveDate);
                return null;
            }
            set
            {
                if (value.HasValue) _receiveDate = DateUtil.Serialize(value.Value);
                else _receiveDate = null;
            }
        }
        [DataMember]
        public bool IsNew { get; set; } 
        #endregion
    }
}
 
        